/*
 * @Autor: dc
 * @Date: 2022-03-31 16:41:35
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2022-10-18 16:14:08
 * @Description: 松土
 */
import React, { Component } from 'react';
import store from '../../../../redux/store'
import $ from 'jquery'
import './index.scss'

import { Toast } from 'antd-mobile'
import { actionBarConfig } from '../../../../redux/action/tree'


class index extends Component {
    // 松土
    diggingFun = () => {
        console.log('松土')
        const { treeAnimation, addEnergy } = this.props
        const { operationArr } = store.getState()
        const { prepare,cooling} = operationArr.find(item => item.name === '松土')
        if (prepare > 0) {
            Toast.show({
                content: '请耐心等待, 松土充能中',
                maskClickable: false,
            })
            return;
        }
        $('.excavation').animate({
            "right": "28%",
            "bottom": "5%",
            "opacity": '1'
        }, 1500, function () {
            store.dispatch(actionBarConfig({
                name: '松土',
                prepare: cooling,
            }, 1000))
            $('.excavation').addClass('scale');
            setTimeout(() => {
                $('.excavation').removeClass('scale');
                $('.excavation').animate({
                    "opacity": '0'
                }, 500)
                setTimeout(() => {
                    $('.excavation').css({ "bottom": "20%", 'right': 0 })
           
                    treeAnimation();
                    addEnergy();
                }, 1500)

            }, 2000)
        })

    }
    render() {
        return (
            <div className="excavation pos_r">
                <div className="excavation_img">
                    <img src={require('../../../../assets/operation/shovel.png')}
                        alt="" />
                    <img className="soil" src={require('../../../../assets/operation/soil.png')}
                        alt="" />
                </div>
            </div>
        );
    }
}

export default index;